package com.goldplusgold.tradedelay.app.market.pojo;


import android.graphics.Color;

import com.goldplusgold.tradedelay.app.market.widget.chartutil.ColorUtil;
import com.goldplusgold.tradedelay.app.market.widget.chartutil.DateUtil;
import com.goldplusgold.tradedelay.app.market.widget.chartutil.NumberUtil;

import static com.goldplusgold.tradedelay.app.market.widget.chartview.ChartConstant.INDEX_KDJ;
import static com.goldplusgold.tradedelay.app.market.widget.chartview.ChartConstant.INDEX_MACD;
import static com.goldplusgold.tradedelay.app.market.widget.chartview.ChartConstant.INDEX_VOL;
import static com.goldplusgold.tradedelay.app.market.widget.chartview.ChartConstant.INDEX_ZJ;

/**
 * Created by Administrator on 2016/8/10.
 */
public class CrossBean {
    //价格x轴
    public float x;
    //价格x轴
    public String rate;
    //价格y轴
    public float y;
    //均线y轴
    public float y2;
    //价格
    public String price;
    //价格
    public long volume;
    //时间
    public long time;
    //年月日时间（有则先取）
    public String timeYMD;
    //十字线显示时，指标左上的文字数组
    public String[] indexText;
    //对应indexText的颜色
    public int[] indexColor;

    public CrossBean(float x, float y) {
        this.x = x;
        this.y = y;
    }

    public CrossBean() {

    }

    public String getTime() {
        if (timeYMD == null)
            return DateUtil.getShortDateJustHour(time);
        return timeYMD;
    }


    /**
     * 设置指标左上角的文字
     *
     * @param data
     */
    public void setIndexTexts(StickData data, int indexType) {
        switch (indexType) {
            case INDEX_VOL:
                indexText = new String[4];
                indexText[0] = "VOL:" + data.getCount();
                indexText[1] = "MA5:" + data.getCountSma5();
                indexText[2] = "MA10:" + data.getCountSma10();
                indexText[3] = "MA20:" + data.getCountSma20();
                indexColor = new int[]{
                        data.isRise() ? ColorUtil.COLOR_RED : ColorUtil.COLOR_GREEN,
                        ColorUtil.COLOR_SMA5,
                        ColorUtil.COLOR_SMA10,
                        ColorUtil.COLOR_SMA20
                };
                break;
            case INDEX_ZJ:
                indexText = new String[4];
                indexText[0] = "超大:" + data.getSp();
                indexText[1] = "大:" + data.getBg();
                indexText[2] = "中:" + data.getMd();
                indexText[3] = "小:" + data.getSm();
                indexColor = new int[]{
                        ColorUtil.COLOR_ZJ_SUPER,
                        ColorUtil.COLOR_ZJ_BIG,
                        ColorUtil.COLOR_ZJ_MIDDLE,
                        ColorUtil.COLOR_ZJ_SMALL
                };
                break;
            case INDEX_MACD:
                indexText = new String[4];
                indexText[0] = "MACD(12,26,9)";
                indexText[1] = "DIF：" + NumberUtil.beautifulDouble(data.getDif());
                indexText[2] = "DEA：" + NumberUtil.beautifulDouble(data.getDea());
                indexText[3] = "MACD：" + NumberUtil.beautifulDouble(data.getMacd());
                indexColor = new int[]{
                        Color.BLACK,
                        ColorUtil.COLOR_DIF,
                        ColorUtil.COLOR_DEA,
                        ColorUtil.COLOR_MACD
                };
                break;
            case INDEX_KDJ:
                indexText = new String[4];
                indexText[0] = "KDJ(9,3,3)";
                indexText[1] = "K：" + NumberUtil.beautifulDouble(data.getK());
                indexText[2] = "D：" + NumberUtil.beautifulDouble(data.getD());
                indexText[3] = "J：" + NumberUtil.beautifulDouble(data.getJ());
                indexColor = new int[]{
                        Color.BLACK,
                        ColorUtil.COLOR_KDJ_K,
                        ColorUtil.COLOR_KDJ_D,
                        ColorUtil.COLOR_KDJ_J
                };
                break;
        }

    }
}
